package scoutobahn.spielwiese.xml;

import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class Townfinder {
    
    // Flotest

    public static void main(String[] args) throws SAXException, IOException, ParserConfigurationException, XPathExpressionException {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.parse("/home/mark/git/scoutobahn/scoutobahn/src/highways.xml");
        XPathFactory xPathfactory = XPathFactory.newInstance();
        XPath xpath = xPathfactory.newXPath();
        XPathExpression expr = xpath.compile("//tag[@v='A 5']");
        NodeList nodeList = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
        for(int i = 0; i < nodeList.getLength(); i++) {
            System.out.println(nodeList.item(i).getParentNode().getChildNodes());
        }
        
 
    }

}
